package net.betou.cms.dao.assist.impl;

import net.betou.cms.dao.assist.CmsVoteReplyDao;
import net.betou.cms.entity.assist.CmsVoteReply;
import net.betou.common.hibernate3.Finder;
import net.betou.common.hibernate3.HibernateBaseDao;
import net.betou.common.page.Pagination;

import org.springframework.stereotype.Repository;

@Repository
public class CmsVoteReplyDaoImpl extends HibernateBaseDao< CmsVoteReply, Integer > implements CmsVoteReplyDao{

	public Pagination getPage( Integer subTopicId, int pageNo, int pageSize ) {
		String hql = "select bean from CmsVoteReply bean";
		Finder f = Finder.create( hql );
		if( subTopicId != null ){
			f.append( " where bean.subTopic.id=:subTopicId" ).setParam( "subTopicId", subTopicId );
		}
		return find( f, pageNo, pageSize );
	}

	public CmsVoteReply findById( Integer id ) {
		CmsVoteReply entity = get( id );
		return entity;
	}

	public CmsVoteReply save( CmsVoteReply bean ) {
		getSession( ).save( bean );
		return bean;
	}

	public CmsVoteReply deleteById( Integer id ) {
		CmsVoteReply entity = super.get( id );
		if( entity != null ){
			getSession( ).delete( entity );
		}
		return entity;
	}

	@Override
	protected Class< CmsVoteReply > getEntityClass( ) {
		return CmsVoteReply.class;
	}
}